package dialer.client.web.controlador;

import java.io.Serializable;

import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.SessionScoped;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import dialer.ws.base.entity.Campaign;
import dialer.ws.business.service.CallService;
import dialer.ws.business.service.CampaignService;
import dialer.ws.common.util.FacesUtils;

@ManagedBean(name = "report")
@SessionScoped
public class ReportController implements Serializable {

	private static final long serialVersionUID = -5014516077962494406L;

	private static final Log log = LogFactory.getLog(ReportController.class);

	private Integer id_campaign;

	private Integer valueGestionValido;

	private Integer valueGestionInvalido;

	private Integer valueEnProceso;

	private Integer valueProximosProceso;

	private Integer valueGestion;

	@ManagedProperty("#{callService}")
	private CallService callService;

	@ManagedProperty("#{campaignService}")
	private CampaignService campaignService;

	public ReportController() {

	}

	@PostConstruct
	public void init() {

	}

	public void refreshPanelDisplay() {
		InitLoad dc = (InitLoad) FacesUtils.getManagedBean("initLoad");

		Campaign campaign = new Campaign();
		for (Campaign c : dc.getListCampaign()) {
			if (c.getId().equals(id_campaign)) {
				campaign = c;
			}
		}

		valueGestionValido = callService.getProcesValidFinish(campaign.getId(), campaign.getRetries());
		valueGestionInvalido = callService.getProcesInvValidFinish(campaign.getId(), campaign.getRetries());
		valueEnProceso = callService.getProcesGestion(campaign.getId(), campaign.getRetries());
		valueProximosProceso = callService.getProcesNoGestion(campaign.getId(), campaign.getRetries());
		valueGestion = callService.getTotalProcesGestion(campaign.getId(), campaign.getRetries());
	}

	public Integer getValueGestionValido() {
		return valueGestionValido;
	}

	public void setValueGestionValido(Integer valueGestionValido) {
		this.valueGestionValido = valueGestionValido;
	}

	public Integer getValueGestionInvalido() {
		return valueGestionInvalido;
	}

	public void setValueGestionInvalido(Integer valueGestionInvalido) {
		this.valueGestionInvalido = valueGestionInvalido;
	}

	public Integer getValueEnProceso() {
		return valueEnProceso;
	}

	public void setValueEnProceso(Integer valueEnProceso) {
		this.valueEnProceso = valueEnProceso;
	}

	public Integer getValueProximosProceso() {
		return valueProximosProceso;
	}

	public void setValueProximosProceso(Integer valueProximosProceso) {
		this.valueProximosProceso = valueProximosProceso;
	}

	public CallService getCallService() {
		return callService;
	}

	public void setCallService(CallService callService) {
		this.callService = callService;
	}

	public Integer getId_campaign() {
		return id_campaign;
	}

	public void setId_campaign(Integer id_campaign) {
		this.id_campaign = id_campaign;
	}

	public CampaignService getCampaignService() {
		return campaignService;
	}

	public void setCampaignService(CampaignService campaignService) {
		this.campaignService = campaignService;
	}

	public Integer getValueGestion() {
		return valueGestion;
	}

	public void setValueGestion(Integer valueGestion) {
		this.valueGestion = valueGestion;
	}

}
